
clearvars -except Globaloption option 

%% Saving parameter estimates to automatically update the paper
fID = fopen(['../../results/tables_main/US/post1946/TableEst_post_US_cy.tex'], 'w');


%% Baseline Results

loaddata_4CIjoint_annual_cy;

cy_gdp_a = cy_gdp_a(2:end);
weighted_cy = m.mult .* m.spread;


fprintf(fID,'\\newcommand{\\cymeanUSpostpct}{%4.2f}\n',mean(cy*100));
fprintf(fID,'\\newcommand{\\cymeanUSpostbps}{%4.1f}\n',mean(cy)*10000);
fprintf(fID,'\\newcommand{\\cygdpmeanUSpostpct}{%4.2f}\n',mean(cy_gdp_a)*100);
fprintf(fID,'\\newcommand{\\cygdpmeanUSpostbps}{%4.2f}\n',mean(cy_gdp_a)*10000);
fprintf(fID,'\\newcommand{\\CSmeanconvenience}{%4.2f}\n', mean(weighted_cy)*100);


load MAT/CS_ConvYield.mat
load MAT/Campbell_Shiller_CY

fprintf(fID,'\\newcommand{\\cyupperUSpost}{%4.2f}\n',upper);
fprintf(fID,'\\newcommand{\\cysmeanUSpost}{%4.2f}\n',mean(s));

fprintf(fID,'\\newcommand{\\cyupperUSpostpct}{%4.2f}\n',100*upper);
fprintf(fID,'\\newcommand{\\cysmeanUSpostpct}{%4.2f}\n',100*mean(s));
fprintf(fID,'\\newcommand{\\postuspvscytodebt}{%4.2f}\n',100*nanmean(s)/nanmean(gdebt));
fprintf(fID,'\\newcommand{\\postuscorrpvscydebt}{%4.2f}\n',corr(gdebt(2:end), s'));
fprintf(fID,'\\newcommand{\\postusuppertodebt}{%4.2f}\n',100*upper/nanmean(gdebt));
fprintf(fID,'\\newcommand{\\postuspdgdpcy}{%4.2f}\n',mean(exp(pxbar)));

load MAT/CS_ConvYield_robust.mat
load MAT/Campbell_Shiller_CY_robust.mat

fprintf(fID,'\\newcommand{\\cyupperUSposttwopct}{%4.2f}\n',upper);
fprintf(fID,'\\newcommand{\\cysmeanUSposttwopct}{%4.2f}\n',mean(s));

fprintf(fID,'\\newcommand{\\cyupperUSpostpcttwopct}{%4.2f}\n',100*upper);
fprintf(fID,'\\newcommand{\\cysmeanUSpostpcttwopct}{%4.2f}\n',100*mean(s));
fprintf(fID,'\\newcommand{\\postuspvscytodebttwopct}{%4.2f}\n',100*nanmean(s)/nanmean(gdebt));
fprintf(fID,'\\newcommand{\\postuscorrpvscydebttwopct}{%4.2f}\n',corr(gdebt(2:end), s'));
fprintf(fID,'\\newcommand{\\postusuppertodebttwopct}{%4.2f}\n',100*upper/nanmean(gdebt));
fprintf(fID,'\\newcommand{\\postuspdgdpcytwopct}{%4.2f}\n',mean(exp(pxbar)));


%% Close File
fclose(fID); 

